#include <ximera/system/appsettings.hpp>
#include <ximera/exception.hpp>

namespace ximera { namespace system
{
    AppSettings::AppSettings()
    {
    }

    AppSettings::AppSettings(char const* argv, int argc)
    {
        parse(argv, argc);
    }

    void AppSettings::clear()
    {
        _values.clear();
    }

    void AppSettings::parse(char const* argv, int argc)
    {
    }

    bool AppSettings::contains(String const& name) const
    {
        return (_values.count(name) == 1);
    }
    
    String const& AppSettings::value(String const& name) const
    {
        ValueMap::const_iterator it = _values.find(name);
        if (it == _values.end())
            XIMERA_THROW(ximera::ItemNotFoundException, L"Could not find: " + name);

        return it->second;
    }

    String& AppSettings::value(String const& name)
    {
        return _values[name];
    }

    void AppSettings::value(String const& name, String const& value)
    {
        _values[name] = value;
    }

    String const& AppSettings::operator[](String const& name) const
    {
        return value(name);
    }

    String& AppSettings::operator[](String const& name)
    {
        return value(name);
    }
}}